import http from '@/utils/request.js'

// 获取用户频道信息
export const getUserChannels = () => {
  return http({
    method: 'GET',
    url: '/app/v1_0/user/channels'
  })
}

// 用户登录
export const login = data => {
  return http({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    data
  })
}
// 发送短信验证码
export const sendSms = mobile => {
  return http({
    method: 'GET',
    url: `/app/v1_0/sms/codes/${mobile}`
  })
}

// 导入store
// import store from '@/store/'

// 获取用户自己信息
export const getUserinfo = () => {
  return http({
    method: 'GET',
    url: `/app/v1_0/user`
    // headers: {
    //   Authorization: `Bearer ${store.state.loginStore.user.token}`
    // }
  })
}
// 获取用户个人资料
export const getUserProfile = () => {
  return http({
    method: 'GET',
    url: `/app/v1_0/user/profile`
  })
}

// 修改用户
export const updataUserProfile = data => {
  return http({
    method: 'PATCH',
    url: `/app/v1_0/user/profile`,
    data
  })
}

// 修改用户头像
export const updataUserPhoto = data => {
  return http({
    method: 'PATCH',
    url: `/app/v1_0/user/photo`,
    data
  })
}

// 关注用户
export const followUser = userId => {
  return http({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}

// 取消关注用户
export const unFollowUser = userId => {
  return http({
    method: 'DELETE',
    url: `/app/v1_0/user/followings/${userId}`
  })
}
// 关注列表
export const upgs = data => {
  return http({
    method: 'GET',
    url: `/app/v1_0/user/followings`,
    data
  })
}
